Skip to content

Conversation

@alxkm
Copy link
Contributor

@alxkm alxkm commented Aug 6, 2025

Summary

This PR adds extensive test coverage for OllamaChatModel and OllamaEmbeddingModel to improve robustness and catch edge cases.

Changes Made

OllamaChatModel Tests

  • Builder validation: Tests for null API validation and complete builder options
  • Metadata handling: Edge cases with zero, large, and null values
  • Aggregation scenarios: Complex metadata aggregation and overflow handling
  • Model configuration: Parameterized tests for different OllamaModel types
  • Data preservation: Model name and timestamp handling in metadata
  • Immutability: Verification that builder creates distinct instances

OllamaEmbedding Tests

  • Input handling: Empty inputs, multiple inputs, and input order preservation
  • Options override: Runtime options properly overriding defaults
  • Keep-alive formats: Different duration formats (seconds, hours, etc.)
  • Minimal configuration: Tests with bare minimum settings
  • Whitespace handling: Preservation of whitespace-only and empty inputs

Test Coverage Improvements

  • Edge case handling for boundary values and null inputs
  • Robust validation of configuration options and their precedence
  • Data integrity verification for metadata aggregation
  • Comprehensive input format testing

Quality Assurance

  • All tests follow existing patterns using AssertJ assertions
  • Maintains consistency with current test structure
  • Uses appropriate mocking with Mockito where needed
  • Includes parameterized tests for efficiency

These tests help ensure the Ollama integration handles various real-world scenarios correctly and maintains backward compatibility.


import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assertions.*;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No wildcard imports.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it was before. Fixed.

Signed-off-by: Alex Klimenko <[email protected]>
@alxkm alxkm requested a review from sobychacko August 6, 2025 19:25
@sobychacko sobychacko added this to the 1.1.0.M1 milestone Aug 6, 2025
@sobychacko sobychacko merged commit 8676d45 into spring-projects:main Aug 6, 2025
2 checks passed
juntae6942 pushed a commit to juntae6942/spring-ai that referenced this pull request Aug 7, 2025
…ingModel` (spring-projects#4038)

* Add comprehensive tests for OllamaChatModel and OllamaEmbeddingModel

Signed-off-by: Alex Klimenko <[email protected]>
scionaltera pushed a commit to scionaltera/spring-ai that referenced this pull request Sep 3, 2025
…ingModel` (spring-projects#4038)

* Add comprehensive tests for OllamaChatModel and OllamaEmbeddingModel

Signed-off-by: Alex Klimenko <[email protected]>
chedim pushed a commit to couchbaselabs/spring-ai that referenced this pull request Sep 19, 2025
…ingModel` (spring-projects#4038)

* Add comprehensive tests for OllamaChatModel and OllamaEmbeddingModel

Signed-off-by: Alex Klimenko <[email protected]>
Willam2004 pushed a commit to Willam2004/spring-ai that referenced this pull request Oct 11, 2025
…ingModel` (spring-projects#4038)

* Add comprehensive tests for OllamaChatModel and OllamaEmbeddingModel

Signed-off-by: Alex Klimenko <[email protected]>
Signed-off-by: 家娃 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants